package com.yc.fruitmarket.controller;

import java.util.List;
import java.util.Map;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.yc.fruitmarket.biz.discountcardBiz;
import com.yc.fruitmarket.biz.impl.discountcardBizImpl;

@WebServlet("/discountcardController/*")
public class discountcardController extends BaseServlet {
	private discountcardBiz db = new discountcardBizImpl();
	//根据获取优惠卷id得到优惠金钱
	public void getDiscount(HttpServletRequest req, HttpServletResponse resp) {
		String did = req.getParameter("did");
		
		if("".equals(did)) {
			return;
		}else {
			List<Map<String, String>>  list = db.getDiscount(did);
			if(list.size()>0) {
				this.send(resp, list.get(0));
			}else {
				return;
			}
		}
	}
	public void findDiscountcard(HttpServletRequest req, HttpServletResponse resp) {
		Map<String,String> map = (Map<String, String>) req.getSession().getAttribute("userInfo");
		String uid = map.get("uid");
		if("".equals(uid)) {
			return;
		}
		List<Map<String, String>> list = db.findDiscountcard(uid);
		if(list.size() > 0) {
			this.send(resp, list);
		}else {
			return;
		}
	}
}
